package Work20241116;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author zdl
 * @date 2024/11/16
 */
public class Demo10 {
    public static void main(String[] args) {
        //18、输入3个小组，每组5人的同学成绩，x，平均分和全班的总分与平均分。
        Scanner sc = new Scanner(System.in);
//        int[] arr = new int[3];
        int[][] stu = new int[3][5];
        for (int i = 0; i < 3; i++) {
            System.out.print("请第" + (i + 1) + "小组,");
            for (int j = 0; j < 5; j++) {
                System.out.println("第" + (j + 1) + "名同学输入成绩");
                int score = sc.nextInt();
                stu[i][j] = score;
            }
        }
        System.out.println(Arrays.deepToString(stu));
        //循环外面  用于统计全班学生成绩
        int allSum = 0;
        for (int i = 0; i < 3; i++) {//组
            //放置在组内循环  用于统计各个小组的总分
            int sum = 0;
            for (int j = 0; j < 5; j++) {//组内的人
                sum += stu[i][j]; //小组的总分
                allSum+= stu[i][j];
            }
            double avg = sum*1.0/5;  //小组的平均分
            System.out.println("第"+(i+1)+"组的总分为:"+sum+",平均分为:"+avg);
        }

        double allAvg = allSum * 1.0 / 15;
        System.out.println("全班总分:" + allSum);
        System.out.println("全班平均分:" + allAvg);
    }
}
